package cn.codeforfun.config;

import cn.codeforfun.auth.AuthService;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.MediaType;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

import static org.springframework.web.reactive.function.server.RequestPredicates.accept;

/**
 * @author wangbin
 */
@Configuration(proxyBeanMethods = false)
public class RouterConfig {
    @Bean
    public RouterFunction<ServerResponse> authApis(AuthService authService) {
        return RouterFunctions.route()
                .POST("/auth/getAuth", accept(MediaType.APPLICATION_JSON), authService::getAuth)
                .build();
    }
}
